//
//  JMCouponListHeadView.m
//  SYPerfectDemo
//
//  Created by Lssyyy on 2019/7/19.
//  Copyright © 2019年 Lssyyy. All rights reserved.
//

#import "JMCouponListHeadView.h"

@implementation JMCouponListHeadView{
    UIView *_sepView;
    UIView *_colorView;
    UILabel *_titleLabel;
    UILabel *_detaiLabel;
    NSInteger _index;
}

- (instancetype)initWithIndex:(NSInteger)index{
    if (self = [super init]) {
        _index = index;
        [self layoutUI];
    }
    return self;
}

- (void)layoutUI{
    self.backgroundColor = [UIColor whiteColor];
    _sepView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,kScreenWidth, 5)];
    _sepView.backgroundColor = UIColorWithRGB16Radix(0xF3F3F3);
    [self addSubview:_sepView];
    
    _colorView = [[UIView alloc]init];
    _colorView.backgroundColor = UIColorWithRGB16Radix(0xFF991F);
    [self addSubview:_colorView];
    _colorView.sd_layout
    .leftSpaceToView(self, 15)
    .heightIs(12)
    .widthIs(2)
    .topSpaceToView(_sepView, 16);
    
    _titleLabel = [UILabel new];
    _titleLabel.textColor = UIColorWithRGB16Radix(0x282828);
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _titleLabel.text = _index == 0? @"可用优惠券" : @"不可用优惠券";
    [self addSubview:_titleLabel];
    _titleLabel.sd_layout
    .leftSpaceToView(_colorView, 7)
    .centerYEqualToView(_colorView)
    .rightSpaceToView(self, 15)
    .heightIs(15);
    
    if (_index != 1) {
        _detaiLabel = [UILabel new];
        _detaiLabel.textColor = UIColorWithRGB16Radix(0xB2B2B2);
        _detaiLabel.font = [UIFont systemFontOfSize:13];
        _detaiLabel.text = @"同一个订单只能用一张优惠券";
        [self addSubview:_detaiLabel];
        _detaiLabel.sd_layout
        .leftEqualToView(_titleLabel)
        .topSpaceToView(_titleLabel, 7)
        .rightSpaceToView(self, 15)
        .heightIs(15);
    }
   
}

@end
